package com.scs.application.modules.adm.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.core.query.QueryContext;
import com.scs.application.core.query.QueryContextHolder;
import com.scs.application.modules.adm.entity.MatrApplyItem;
import com.scs.application.modules.adm.service.MatrApplyItemService;
import com.scs.application.modules.sys.model.PageResult;
import com.scs.application.modules.sys.model.RestResult;
import com.google.common.collect.Maps;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 耗材准入申请单明细 前端控制器
 * </p>
 */
@RestController
@RequestMapping("/adm/matr_apply_item")
public class MatrApplyItemController extends CrudController<MatrApplyItemService, MatrApplyItem>{
    /**
     * @Description： 耗材准入申请单明细视图-审批添加时使用
     */
    @GetMapping("/pageForAuditAdd")
    public RestResult pageForAuditAdd(@RequestParam Map<String, Object> reqData){
        QueryContext queryContext = QueryContextHolder.currentContext();
        Map<String, Object> userParam =null;
        //固定参数
        if(reqData.containsKey("userParam")){
            JSONObject ob = JSON.parseObject(reqData.get("userParam")+"");
            userParam= Maps.newHashMap(ob);
        }


        IPage pageResult = service.pageForAuditAdd(queryContext,userParam);
        return PageResult.ok("查询成功", pageResult.getRecords(), pageResult.getTotal());
    }
}
